<?php

namespace Apps\Common\Models;

/**
 * 平台管理操作员Model
 * @author     chenxiaolin
 * @date        2016年1月19日
 * @version     2.0.0
 * @copyright   Copyright 2016 meelier.com
 */
class BackendOperator extends \PhalconPlus\Database\Model
{

    /**
     *
     * @var integer
     */
    public $operator_id;

    /**
     *
     * @var string
     */
    public $operator_account;

    /**
     *
     * @var string
     */
    public $operator_show_name;

    /**
     *
     * @var string
     */
    public $operator_password;

    /**
     *
     * @var integer
     */
    public $operator_role;

    /**
     *
     * @var integer
     */
    public $operator_group;

    /**
     *
     * @var string
     */
    public $operator_remark;

    /**
     *
     * @var integer
     */
    public $operator_state;

    /**
     *
     * @var string
     */
    public $operator_addtime;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        $this->hasMany('operator_id', 'Apps\Common\Models\BackendOperatorLog', 'operator_id', array('alias' => 'BackendOperatorLog'));
        $this->belongsTo('operator_group', 'Apps\Common\Models\BackendOperatorGroup', 'group_id', array('alias' => 'BackendOperatorGroup'));
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'backend_operator';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return BackendOperator[]
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return BackendOperator
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    /**
     * Independent Column Mapping.
     * Keys are the real names in the table and the values their names in the application
     *
     * @return array
     */
    public function columnMap()
    {
        return array(
            'operator_id' => 'operator_id',
            'operator_account' => 'operator_account',
            'operator_show_name' => 'operator_show_name',
            'operator_password' => 'operator_password',
            'operator_role' => 'operator_role',
            'operator_group' => 'operator_group',
            'operator_remark' => 'operator_remark',
            'operator_state' => 'operator_state',
            'operator_addtime' => 'operator_addtime'
        );
    }

    public function defaultColumns()
    {
        return [
            'operator_remark',
            'operator_state',
            'operator_addtime',
        ];
    }

}
